home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
PAS_0793
/
NUMBTEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-08-01
|
3KB
|
66 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 306 of 323
From : Mark Lewis 1:3634/12.0 05 Jul 93 21:38
To : all 1:3634/12.0
Subj : (2 of 2) number base conversions
────────────────────────────────────────────────────────────────────────────────}
Program NUMBTEST;
uses NUMBase, CRT;
begin
clrscr;
write('DEC2BASE - Function Dec2Base(number: LongInt; ' +
'base,str_length: Byte): String;');
writeln;
write('dec2base(10,10,4) : '+dec2base(10,10,4));
if nubase_err then writeln(' Range Error') else writeln;
write('dec2base(-10,10,4) : '+dec2base(-10,10,4));
if nubase_err then writeln(' Range Error') else writeln;
write('dec2base(-10,10,2) : '+dec2base(-10,10,2));
if nubase_err then writeln(' Range Error') else writeln;
write('dec2base(10,16,4) : '+dec2base(10,16,4));
if nubase_err then writeln(' Range Error') else writeln;
writeln;
writeln('BASE2DEC - Function Base2Dec(number: String; ' +
'base: Byte): LongInt;');
writeln;
write('base2dec('''+dec2base(-10,16,4)+''',16) : ',
base2dec(dec2base(-10,16,4),16));
if nubase_err then writeln(' Range Error') else writeln;
write('base2dec(''A'',16) : ',base2dec('A',16));
if nubase_err then writeln(' Range Error') else writeln;
write('base2dec(''-A'',16) : ',base2dec('-A',16));
if nubase_err then writeln(' Range Error') else writeln;
write('base2dec(''000A'',36) : ',base2dec('000A',36));
if nubase_err then writeln(' Range Error') else writeln;
write('base2dec(''a'',16) : ',base2dec('a',16));
if nubase_err then writeln(' Range Error') else writeln;
write('base2dec(''a'',36) : ',base2dec('a',36));
if nubase_err then writeln(' Range Error') else writeln;
write('base2dec(''a'',62) : ',base2dec('a',62));
if nubase_err then writeln(' Range Error') else writeln;
writeln('base2dec('''+dec2base(36,36,4)+''',36) : ',
base2dec(dec2base(36,36,2),36));
if nubase_err then writeln(' Range Error') else writeln;
write('HEX to BIN : 0010h -> ??b : ' +
dec2base(base2dec(''0010'',16),2,8) : ');
writeln(dec2base(base2dec('10',16),2,8));
write('HEX to OCT : 0010h -> ??o : ' +
dec2base(base2dec(''0010'',16),8,8) : ');
writeln(dec2base(base2dec('10',16),8,8));
write('OCT to BIN : 0020o -> ??b : ' +
dec2base(base2dec(''0020'',8),2,8) : ');
writeln(dec2base(base2dec('20',8),2,8));
write('BIN to DEC : 1011b -> ??d : ' +
dec2base(base2dec(''1011'',2),10,8) : ');
writeln(dec2base(base2dec('1011',2),10,8));
write('BIN to OCT : 1011b -> ??o : ' +
dec2base(base2dec(''1011'',2),8,8) : ');
writeln(dec2base(base2dec('1011',2),8,8));
write('BIN to HEX : 1011b -> ??h : ' +
dec2base(base2dec(''1011'',2),16,8) : ');
writeln(dec2base(base2dec('1011',2),16,8));
write('Press <ENTER> : ');
readln;
end.